namespace AgorApp.Roma.Model.DataTransferObjects
{
    using AgorApp.Roma.Model.DataTransferObjects.Utils;
    using Newtonsoft.Json;
    using System;
    using System.Collections.Generic;

    /// <summary>
    /// 
    /// </summary>
    public partial class GruppiConsiliari : IEntityObjectState, IEquatable<GruppiConsiliari>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="GruppiConsiliari"/> class.
        /// </summary>
        public GruppiConsiliari()
        {
            this.IdGruppo = ShortIdKeeper.Next();
            this.DataInserimento = DateTimeOffset.Now;
            this.UtenteInserimento = "System";

            this.ConsiglieriAssemblea = new List<ConsiglieriAssemblea>();
            this.GruppiConsiliariImages = new List<GruppiConsiliariImages>();
            this.Tags = new List<Tag>();
        }

        /// <summary>
        /// Gets or sets the identifier gruppo.
        /// </summary>
        /// <value>
        /// The identifier gruppo.
        /// </value>
        public short IdGruppo { get; set; }
        /// <summary>
        /// Gets or sets the denominazione.
        /// </summary>
        /// <value>
        /// The denominazione.
        /// </value>
        public string Denominazione { get; set; }
        /// <summary>
        /// Gets or sets the sigla.
        /// </summary>
        /// <value>
        /// The sigla.
        /// </value>
        public string Sigla { get; set; }
        /// <summary>
        /// Gets or sets the note.
        /// </summary>
        /// <value>
        /// The note.
        /// </value>
        public NoteObj Note { get; set; }
        /// <summary>
        /// Gets or sets a value indicating whether [in maggioranza].
        /// </summary>
        /// <value>
        ///   <c>true</c> if [in maggioranza]; otherwise, <c>false</c>.
        /// </value>
        public bool InMaggioranza { get; set; }
        /// <summary>
        /// Gets or sets the data inserimento.
        /// </summary>
        /// <value>
        /// The data inserimento.
        /// </value>
        public System.DateTimeOffset DataInserimento { get; set; }
        /// <summary>
        /// Gets or sets the utente inserimento.
        /// </summary>
        /// <value>
        /// The utente inserimento.
        /// </value>
        public string UtenteInserimento { get; set; }
        /// <summary>
        /// Gets or sets the data aggiornamento.
        /// </summary>
        /// <value>
        /// The data aggiornamento.
        /// </value>
        public Nullable<System.DateTimeOffset> DataAggiornamento { get; set; }
        /// <summary>
        /// Gets or sets the utente aggiornamento.
        /// </summary>
        /// <value>
        /// The utente aggiornamento.
        /// </value>
        public string UtenteAggiornamento { get; set; }
        /// <summary>
        /// Gets or sets the data fine validita record.
        /// </summary>
        /// <value>
        /// The data fine validita record.
        /// </value>
        public Nullable<System.DateTimeOffset> DataFineValiditaRec { get; set; }
        /// <summary>
        /// Gets or sets the utente cancellazione record.
        /// </summary>
        /// <value>
        /// The utente cancellazione record.
        /// </value>
        public string UtenteCancellazioneRec { get; set; }

        /// <summary>
        /// Classe per la mappatura di <see cref="Note"/>
        /// </summary>
        public class NoteObj
        {
            [JsonProperty(PropertyName = "html")]
            public string TestoHtml { get; set; }
            [JsonProperty(PropertyName = "plain")]
            public string TestoPlain { get; set; }
        }

        #region Related Entities        
        /// <summary>
        /// Gets or sets the consiglieri assemblea.
        /// </summary>
        /// <value>
        /// The consiglieri assemblea.
        /// </value>
        public virtual ICollection<ConsiglieriAssemblea> ConsiglieriAssemblea { get; set; }
        /// <summary>
        /// Gets or sets the gruppi consiliari images.
        /// </summary>
        /// <value>
        /// The gruppi consiliari images.
        /// </value>
        public virtual ICollection<GruppiConsiliariImages> GruppiConsiliariImages { get; set; }
        /// <summary>
        /// Gets or sets the tags.
        /// </summary>
        /// <value>
        /// The tags.
        /// </value>
        public virtual ICollection<Tag> Tags { get; set; } 
        #endregion

        /// <summary>
        /// Gets or sets the state of the object.
        /// </summary>
        /// <value>
        /// The state of the object.
        /// </value>
        public EntityObjectState ObjectState { get; set; }

        #region IEquatable        
        /// <summary>
        /// Indicates whether the current object is equal to another object of the same type.
        /// </summary>
        /// <param name="other">An object to compare with this object.</param>
        /// <returns>
        /// true if the current object is equal to the <paramref name="other" /> parameter; otherwise, false.
        /// </returns>
        public bool Equals(GruppiConsiliari other)
        {
            if (null == (object)other || other.GetType() != this.GetType()) return false;
            return this.IdGruppo == other.IdGruppo;
        }
        /// <summary>
        /// Determines whether the specified <see cref="System.Object" />, is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param>
        /// <returns>
        ///   <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public override bool Equals(object obj)
        {
            if (obj == null || obj.GetType() != this.GetType()) return false;

            if (Object.ReferenceEquals(this, obj)) return true;

            var gruppo = obj as GruppiConsiliari;
            if ((object)gruppo == null) return false;
            return this.IdGruppo == gruppo.IdGruppo;
        }
        /// <summary>
        /// Returns a hash code for this instance.
        /// </summary>
        /// <returns>
        /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. 
        /// </returns>
        public override int GetHashCode()
        {
            return this.IdGruppo;
        }
        /// <summary>
        /// Implements the operator ==.
        /// </summary>
        /// <param name="a">a.</param>
        /// <param name="b">The b.</param>
        /// <returns>
        /// The result of the operator.
        /// </returns>
        public static bool operator ==(GruppiConsiliari a, GruppiConsiliari b)
        {
            if (ReferenceEquals(a, b)) return true;
            if (((object)a == null) || ((object)b == null)) return false;
            return a.Equals(b);
        }
        /// <summary>
        /// Implements the operator !=.
        /// </summary>
        /// <param name="a">a.</param>
        /// <param name="b">The b.</param>
        /// <returns>
        /// The result of the operator.
        /// </returns>
        public static bool operator !=(GruppiConsiliari a, GruppiConsiliari b)
        {
            return !(a == b);
        }
        #endregion
    }
}
